package ArrayListTest.homework;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;

/**
 * 集合排序:整型
 */
public class SortInteger {
    public static void main(String[] args) {
        List<Integer> list = new ArrayList<>();
        Random rand = new Random();
        for (int i = 0;i<10;i++){
            list.add(rand.nextInt(100));
        }
        System.out.println("list:"+list);//list:[52, 65, 46, 1, 7, 5, 78, 91, 11, 76]

        Collections.sort(list);
        System.out.println("排序后："+list);//小->大  排序后：[1, 5, 7, 11, 46, 52, 65, 76, 78, 91]

        Collections.reverse(list);
        System.out.println("反转后："+list);//大->小  反转后：[91, 78, 76, 65, 52, 46, 11, 7, 5, 1]

        System.out.println(list.get(0));//91
    }
}
